package io.github.lee.jel.ui.folder

import android.content.Context
import android.content.Intent
import android.graphics.Color
import androidx.core.os.bundleOf
import androidx.databinding.ViewDataBinding
import dagger.hilt.android.AndroidEntryPoint
import io.github.lee.core.ui.BaseActivity
import io.github.lee.core.util.getBundleParcelable
import io.github.lee.core.vm.BaseViewModel
import io.github.lee.jel.R
import io.github.lee.jel.domain.po.JellyfinSession

@AndroidEntryPoint
class MediaFolderActivity : BaseActivity<ViewDataBinding, BaseViewModel>() {

    companion object {
        private const val KEY_SESSION = "SESSION"

        @JvmStatic
        fun start(context: Context, session: JellyfinSession) {
            val starter = Intent(context, MediaFolderActivity::class.java)
                .putExtras(bundleOf(KEY_SESSION to session))
            context.startActivity(starter)
        }
    }

    //===Desc:=============================================================

    override fun onSetViewData() {
        super.onSetViewData()
        statusBarColor(Color.WHITE, true)
        val session = getBundleParcelable(KEY_SESSION, JellyfinSession::class.java)
        if (null == session) {
            toast(getString(R.string.error_application_error))
            finish()
            return
        }
        replaceFragment(MediaFolderFragment.newInstance(session))
    }


}